package middle.id_1_100;

public class hua15 {
    public static void main(String[] args) {
        int[] steps={1,2,3,2,1};
        int[] steps2={0, 1, 2, 0, 2, 4, 2,1,0,1,2,3,2,1,1};
        System.out.println(getMinStep(steps));
    }


    public static int getMinStep2(int[] indentations) {
        int n = indentations.length; // 代码总行数
        int operations = 0; // 初始化最少操作次数为0
        int maxIndent = 0; // 当前行最大缩进长度
        for (int i = 0; i < n; i++) {
            int diff = indentations[i] - maxIndent;
            if (diff > 0) {
                operations += diff;
            }
            maxIndent = indentations[i];
        }
        return operations;
    }
    static int getMinStep(int[] steps) {
        int curmax=0;
        int result=0;
        // 在此补充你的代码
        for(int i=0;i<steps.length;i++){
            if(steps[i]-curmax>0){
                result=result+(steps[i]-curmax);
            }
            curmax=steps[i];
        }
        return result;
    }
}
